server_sources = files(
    'rygel-audio-item.vala',
    'rygel-image-item.vala',
    'rygel-logical-expression.vala',
    'rygel-media-art-store.vala',
    'rygel-media-objects.vala',
    'rygel-music-item.vala',
    'rygel-photo-item.vala',
    'rygel-relational-expression.vala',
    'rygel-simple-container.vala',
    'rygel-subtitle.vala',
    'rygel-thumbnail.vala',
    'rygel-video-item.vala',
    'rygel-media-container.vala',
    'rygel-media-item.vala',
    'rygel-media-file-item.vala',
    'rygel-media-object.vala',
    'rygel-media-resource.vala',
    'rygel-media-server-plugin.vala',
    'rygel-search-expression.vala',
    'rygel-searchable-container.vala',
    'rygel-trackable-container.vala',
    'rygel-trackable-item.vala',
    'rygel-visual-item.vala',
    'rygel-writable-container.vala',
    'rygel-media-server.vala',
    'rygel-media-engine.vala',
    'rygel-http-seek.vala',
    'rygel-data-source.vala',
    'rygel-updatable-object.vala',
    'rygel-playlist-item.vala',
    'rygel-browse.vala',
    'rygel-client-hacks.vala',
    'rygel-content-directory.vala',
    'rygel-dbus-thumbnailer.vala',
    'rygel-engine-loader.vala',
    'rygel-http-byte-seek-request.vala',
    'rygel-http-byte-seek-response.vala',
    'rygel-free-desktop-interfaces.vala',
    'rygel-http-get-handler.vala',
    'rygel-http-get.vala',
    'rygel-http-thumbnail-handler.vala',
    'rygel-http-subtitle-handler.vala',
    'rygel-http-item-uri.vala',
    'rygel-http-post.vala',
    'rygel-http-request.vala',
    'rygel-http-response.vala',
    'rygel-http-response-element.vala',
    'rygel-http-server.vala',
    'rygel-http-time-seek-request.vala',
    'rygel-http-time-seek-response.vala',
    'rygel-http-resource-handler.vala',
    'rygel-import-resource.vala',
    'rygel-object-creator.vala',
    'rygel-reference-creator.vala',
    'rygel-item-destroyer.vala',
    'rygel-item-updater.vala',
    'rygel-object-removal-queue.vala',
    'rygel-last-change-entry.vala',
    'rygel-last-change-obj-add.vala',
    'rygel-last-change-obj-del.vala',
    'rygel-last-change-obj-mod.vala',
    'rygel-last-change-st-done.vala',
    'rygel-last-change.vala',
    'rygel-lg-tv-hacks.vala',
    'rygel-m3u-playlist.vala',
    'rygel-media-query-action.vala',
    'rygel-media-receiver-registrar.vala',
    'rygel-panasonic-hacks.vala',
    'rygel-samsung-tv-hacks.vala',
    'rygel-seek-hacks.vala',
    'rygel-search-criteria-parser.vala',
    'rygel-search.vala',
    'rygel-serializer.vala',
    'rygel-source-connection-manager.vala',
    'rygel-subtitle-manager.vala',
    'rygel-thumbnailer.vala',
    'rygel-wmp-hacks.vala',
    'rygel-xbmc-hacks.vala',
    'rygel-xbmc4xbox-hacks.vala',
    'rygel-xbox-hacks.vala',
    'rygel-phillips-hacks.vala',
    'rygel-data-sink.vala',
    'rygel-playspeed.vala',
    'rygel-playspeed-request.vala',
    'rygel-playspeed-response.vala',
    'rygel-dtcp-cleartext-request.vala',
    'rygel-dtcp-cleartext-response.vala',
    'rygel-dlna-available-seek-request.vala',
    'rygel-dlna-available-seek-response.vala')

server_lib = library('rygel-server-2.8', server_sources,
        dependencies : server_deps + [build_config, rygel_core],
        version: lib_version,
        darwin_versions: darwin_versions,
        c_args : ['-DG_LOG_DOMAIN="RygelServer"'],
        vala_gir : 'Rygel-2.8.gir',
        vala_header : 'rygel-server.h',
        install: true,
        install_dir : [true, rygel_includedir, true, false])
install_data('rygel-server-2.8.deps', install_dir : rygel_vapidir)

if g_ir_compiler.found()
# For details on the GIR/typelib generation process, see
# librygel-core/meson.build
server_gir = custom_target('RygelServer-2.8.gir',
              command: [sed, '-e', 's,Rygel[.],RygelServer.,g',
                                          '-e', 's,namespace name="Rygel",namespace name="RygelServer",g',
                                          '-e', 's,RygelServer[.]StateMachine,RygelCore.StateMachine,g',
                                          '-e', 's,RygelServer[.]Plugin,RygelCore.Plugin,g',
                                          '-e', 's,RygelServer[.]MediaDevice,RygelCore.MediaDevice,g',
                                          '-e', 's,RygelServer[.]IconInfo,RygelCore.IconInfo,g',
                                          '-e', 's,RygelServer[.]DLNAProfile,RygelCore.DLNAProfile,g',
                                          '-e', 's|<package name="rygel-server-2.8"/>|<include name="RygelCore" version="2.8"/><package name="rygel-server-2.8"/>|',
                        join_paths(meson.current_build_dir(), 'Rygel-2.8.gir')],
              output: 'RygelServer-2.8.gir',
              capture: true,
              depends: server_lib,
              install: true,
              install_dir: join_paths(get_option('datadir'),'gir-1.0'))

custom_target('RygelServer-2.8.typelib',
               command: [g_ir_compiler,
                        '--output', '@OUTPUT@',
                        '--includedir', core_girdir,
                        join_paths(meson.current_build_dir(), 'RygelServer-2.8.gir')],
               output: 'RygelServer-2.8.typelib',
               depends: [ server_lib, server_gir, core_gir ],
               install: true,
               install_dir: typelib_dir)

endif

# need to add to get the current build dir as include dir
rygel_server = declare_dependency(include_directories: include_directories('.'),
                                  dependencies : server_deps,
                                  link_with: server_lib)

# necessary to be able to pass it to g-ir-compiler in other libs
server_girdir = meson.current_build_dir()
